package org.mindrive.system.dao;

import org.mindrive.system.collection.system.LogEntity;
import org.mindrive.system.dao.mapper.LogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author houwei
 * @since 2021-10-15
 *
 * @author liu si yuan
 * @since 2023-05-22
 */
@Service
public class LogDao extends ServiceImpl<LogMapper, LogEntity> {

    @Autowired LogMapper logMapper;
    public void createTable(String tableName) {
        logMapper.createTable(tableName);
    }
    public void updateTableName(String tableName) {
        logMapper.updateTableName(tableName);
    }

    public List<Map> selectLogHistory(Map<String, Object> parameter) {

        String tableName = (String) parameter.get("tableName");
        String name = (String) parameter.get("name");
        String userId = (String) parameter.get("userId");
        Date beginTimeDate = (Date) parameter.get("beginTimeDate");
        Date endTimeDate = (Date) parameter.get("endTimeDate");
        String eventType = (String) parameter.get("eventType");
        String curPage = (String) parameter.get("curPage");
        String pageSize = (String) parameter.get("pageSize");

        return logMapper.selectLogHistory(tableName,name,userId,beginTimeDate,endTimeDate,eventType,curPage,pageSize);
    }
    public Integer selectLogHistoryCount(Map<String, Object> parameter) {

        String tableName = (String) parameter.get("tableName");
        String name = (String) parameter.get("name");
        String userId = (String) parameter.get("userId");
        Date beginTimeDate = (Date) parameter.get("beginTimeDate");
        Date endTimeDate = (Date) parameter.get("endTimeDate");
        String eventType = (String) parameter.get("eventType");
        String curPage = (String) parameter.get("curPage");
        String pageSize = (String) parameter.get("pageSize");

        return logMapper.selectLogHistoryCount(tableName,name,userId,beginTimeDate,endTimeDate,eventType,curPage,pageSize);
    }

}
